﻿using System;
using System.Globalization;

using BizElements.BusinessLayer;

namespace BizElements.Web.UI
{
    /// <summary>Business activity monitoring console row.</summary>
    public partial class BamItemRow : System.Web.UI.UserControl
    {
        /// <summary>Format of the URL which is opened when link is clicked.</summary>
        const string SearchUrlFormat = "~/SearchController.aspx?name={0}&guid={1}";

        /// <summary>Sets search link URL.</summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.uiSearchLink.NavigateUrl = string.Format(SearchUrlFormat, this.ProviderKey, Guid.NewGuid());
        }

        /// <summary>Search provider key/method name in SearchController to open.</summary>
        public string ProviderKey { get; set; }

        /// <summary>Title.</summary>
        public string Title
        {
            get { return this.uiSearchLink.Text; }
            set { this.uiSearchLink.Text = value; }
        }

        /// <summary>Count caption.</summary>
        public string CountCaption
        {
            get { return this.uiCountCaption.Text; }
            set { this.uiCountCaption.Text = value; }
        }

        /// <summary>Number of records.</summary>
        public int? Count
        {
            get { return NumberParser.ParseInt(this.uiCount.Text); }
            set { this.uiCount.Text = Convert.ToString(value, CultureInfo.InvariantCulture); }
        }        
    }
}